package com.ali.item.controller;

import com.ali.item.common.DecreaseStockInput;
import com.ali.item.entity.ItemSku;
import com.ali.item.service.ItemSkuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description
 * @Author Alistair.Chow
 * @date 2019/1/28 18:04
 */
@RestController
@RequestMapping("/sku")
public class ItemSkuController {
    @Autowired
    private ItemSkuService itemSkuService;

    @PostMapping("/decreaseStock")
    public void decreaseStock(@RequestBody List<DecreaseStockInput> decreaseStockInputList){
        itemSkuService.decreaseStock(decreaseStockInputList);
    }

    @PostMapping("/findAllByItemIdIn")
    public List<ItemSku> listForOrder(@RequestBody List<Integer> itemIdList){
        return itemSkuService.findAllByItemIdIn(itemIdList);
    }

    @PostMapping("/findAllByIdIn")
    public List<ItemSku> findAllByIdIn(@RequestBody List<Integer> idList){
        return itemSkuService.findAllByIdIn(idList);
    }
}
